<template>
  <div class="box">
    <header>
      <span @click="backFn">
        <van-icon name="arrow-left" />
      </span>
      <flot>我的客户</flot>
      <span></span>
    </header>
    <nav>
      <div class="top">
        <form action="/">
          <van-search
            v-model="value"
            show-action
            placeholder="请输入搜索关键词"
            @search="onSearch"
            @cancel="onCancel"
          />
        </form>
      </div>
    </nav>
    <section>
      <div
        @click="userFn(item)"
        class="child"
        v-for="item in list.value"
        :key="item"
      >
        <div class="left">
          <div class="user_img">{{ item.name[0] }}</div>
          <div class="boxp">
            <p>{{ item.name }}</p>
            <p>{{ item.contact_manner }}</p>
          </div>
        </div>
        <div class="right">
          <van-icon name="phone-o" />
        </div>
      </div>
    </section>
    <footer>
      <dl @click="add">
        <dt><van-icon name="plus" /></dt>
        <dd>添加</dd>
      </dl>
      <dl @click="add1">
        <dt><van-icon name="plus" /></dt>
        <dd>添加企业客户</dd>
      </dl>
    </footer>
  </div>
</template>

<script setup>
import { ref, reactive } from "vue";
import { useRouter } from "vue-router";
import apis from "../../../utils/api_nots";

const list = reactive({ value: [] });
const router = useRouter();

apis
  .get_user({
    size: 50,
    page: 1,
    state: 1,
    wx_xcx_status: 1,
  })
  .then((res) => {
    list.value = res.data.data.data;
  });

// 点击用户
function userFn(v) {
  console.log(v);
  router.push("/add?id=" + v.id);
}
function add() {
  router.push("/add");
}
function add1() {
  router.push("/add1");
}
function backFn() {
  history.go(-1);
}
</script>
<style scoped>
footer {
  width: 100%;
  height: 3rem;
  background: white;
  display: flex;
  align-items: center;
  justify-content: space-around;
  border-top: 1px solid #ccc;
  position: fixed;
  bottom: 0;
}
.right {
  font-size: 2rem;
}
footer dl {
  text-align: center;
  font-size: 1rem;
}
.user_img {
  width: 1rem;
  height: 1rem;
  background: blueviolet;
  color: white;
  padding: 1rem;
  font-size: 1.5rem;
  line-height: 1rem;
  border-radius: 50%;
}
.child {
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.left {
  display: flex;
  align-items: center;
  height: 100%;
}
footer dd {
  text-align: center;
  margin: 0;
  padding: 0;
}
section {
  padding: 6rem 0;
}
header {
  position: fixed;
  top: 0;
  width: 100%;
  height: 2.3rem;
  background: blue;
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
  z-index: 999;
}
header span {
  width: 1.3rem;
  font-size: 1.3rem;
}
nav {
  z-index: 999;
  width: 100%;
  position: fixed;
  top: 2.3rem;
}
</style>
